package com.dbky.alg.core.authorize;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * @Auther: tianchao
 * @Date: 2021/12/19 20:27
 * @Description:
 */
@Component
public class AlgAuthorizeConfigManager implements AuthorizeConfigManager {

    @Autowired(required = false)
    private Set<AuthorizeConfigProvider> authorizeConfigProviders;

    @Override
    public void configure(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) {
        for (AuthorizeConfigProvider authorizeConfigProvider : authorizeConfigProviders) {
            authorizeConfigProvider.configure(registry);
        }
        registry.anyRequest().authenticated();
    }
}
